package com.polaris.live.adapter

import android.text.TextUtils
import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.polaris.live.R
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.ItemGiveFollowerBinding
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo
import com.polaris.live.utils.image.ImageUtils

/**
 * BackPackBubbleAdapter
 *
 * @author Created by 半仙 on 2024/1/31/031 11:44
 */
class GiveFollowerAdapter : BaseBindingAdapter<ItemGiveFollowerBinding, UserBasicVo>() {

    private var mSelectIndex = -1

    init {
        addChildClickViewIds(R.id.give_tv)
    }

    override fun convert(
        holder: VBViewHolder<ItemGiveFollowerBinding>,
        item: UserBasicVo,
    ) {
        holder.vb.apply {
            Glide.with(context)
                .load(ImageUtils.imgPathSmall(item.avatar))
                .transform(CircleCrop())
                .into(avater)
            name.text = item.nickname

            if (TextUtils.isEmpty(item.country)) {
                userCountry.visibility = View.GONE
            } else {
                userCountry.visibility = View.VISIBLE
                userCountry.setCountry(item.country)
            }
            vipView.setVipLevel(item.vipLevel)
            levelView.setRichCharmBySexLevel(
                item.sex,
                item.richs,
                item.charms
            )
        }
    }

    fun setSelect(position: Int) {
        mSelectIndex = position

        notifyItemChanged(mSelectIndex)
    }

}